<template>
  <div class="page-box h100 display-flex czbj" :jhnxdf="jhnxdf">
    <!-- sonRouter="yybureauFormationBJ" 为跳转新的页面编辑 -->
    <dxtable
      v-if="jxcxr"
      :dataJson="dataJson"
      :portUrl="portUrl"
      :formJson="formJson"
      :qx="qx"
      ref="databale"
      czWidth="250"
      @getlistId="getlistId"
    ></dxtable>
  </div>
</template>
<script lang="ts" setup>
import dxtable from "../../../components/util/dxtable.vue";
import sort from "../../../components/util/sort.vue";
import { dxget, dxpost } from "../../../util/index";
import { NButton, NImage, NTag } from "naive-ui";
import { h, ref, reactive, computed } from "vue";
import { useRouter } from "vue-router";
const databale = ref();
const kcxdsr = ref([]);
let njid = ref();
const kcxzcdsf = ref([]);
const jxcxr = ref(false);
const initeer = () => {
  databale.value.initDataExpose();
};

const router = useRouter();

const fdfdsgta = ref([]);
const showModal = ref();
const kcids = ref();
const kcid = ref();
const jigouId = ref();
let dataJson = [
  {
    title: "班级名称",
    key: "name",
    width: "",
    search: true,
  },
  {
    title: "班主任",
    key: "bzrid",
    type: "select",
    options: [],
    search: true,
    width: "",
    render: (row) => {
      try {
        return kcxdsr.value.filter((a) => a.value == row.bzrid)[0].label;
      } catch (e) {
        return "--";
      }
    },
  },
  {
    title: "学生",
    key: "xs",
    width: "",
    search: false,
    render: (row) => {
      try {
        return kcxzcdsf.value.filter((a) => a.idname == row.id)[0].value;
      } catch (e) {
        return 0;
      }
    },
  },

  {
    title: "添加时间",
    key: "addTime",
    width: 150,
  },
];

const qx = {
  DeletePermissionID: "123456", //删除
  EditPermissionIdentifier: "", // 编辑
  NewPermissionIdentifier: "ccurriculumxz222", // 新建
  ViewPermissionID: "ccurriculumck", // 查看
};
const xxid = localStorage.xxid;
const portUrl = ref();

const getlistId = async (ids) => {
  const { data }: any = await dxget("courseManagement/erqi/kmxcdf", {
    bid: ids,
  });
  kcxzcdsf.value = data;
  console.log(data);
};

let formJson = reactive([
  {
    title: "班级名称",
    type: "input",
    val: "",
    span: 12,
    key: "name",
    istable: true,
    required: true,
  },
  {
    title: "班主任",
    type: "select",
    options: [],
    val: "",
    span: 12,
    key: "bzrid",
    istable: true,
    required: false,
  },
  {
    title: "",
    type: "",
    val: "",
    span: 24,
    key: "nianjiid",
    istable: true,
    required: true,
  },
  {
    title: "",
    type: "",
    val: xxid,
    span: 24,
    key: "xxid",
    istable: true,
    required: true,
  },
]);
const jhnxdf = computed(() => {
  jxcxr.value = false;
  njid.value = router.currentRoute.value.query.nianjiid;
  formJson[2].val = njid.value;
  portUrl.value =
    "courseManagement/banji/banji?xxid=" + xxid + "&nianjiid=" + njid.value;
  setTimeout(() => {
    jxcxr.value = true;
  }, 100);
  return router.currentRoute.value.query.nianjiid;
});
// 获取字典内容
const xtgxxmfl = async () => {
  const { data }: any = await dxget("courseManagement/api/geytnxfList", {
    xxid: localStorage.xxid,
  });
  console.log(data);
  formJson[1].options = data;
  dataJson[1].options = [
    {
      label: "全部",
      value: "",
    },
    ...data,
  ];
  kcxdsr.value = data;
};
xtgxxmfl();
</script>
<style scoped></style>
